package com.demo03_feed.controller;

import com.demo03_feed.client.VideoServiceClient;
import com.demo03_feed.service.FollowerService;
import com.demo03_feed.util.ApiResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//Feed服务内部控制器
@RestController
@RequestMapping("/feeds/internal")
@RequiredArgsConstructor
@Slf4j
public class FeedInternalController {
    private final RedisTemplate<String, String> redisTemplate;

    //模拟粉丝服务，实际应该通过Feign调用用户服务来获取粉丝列表
    private final FollowerService followerService;
    private final VideoServiceClient videoServiceClient;

    // 该接口现在主要用于测试，实际推送通过Kafka异步处理
    @PostMapping("/feed")
    public ResponseEntity<ApiResponse<Void>> pushVideoToFollowers(@RequestParam Long videoId, @RequestParam Long authorId){
        // 为了向后兼容，保留该接口，但内部实现改为异步处理
        return ResponseEntity.ok(ApiResponse.success(null));
    }

}